<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button>
        停止
    </button>
    
    <script>
       
        setInterval(p=>{
            console.log(1);
            
        },1000)
        // 延迟执行 只执行1次
        let timer = setTimeout(()=>{
            console.log('我执行了');
            
        },5000)

        let but = document.querySelector('button')
        but.onclick = function(){
            console.log('点停止');
            
            // 停止延时器
            clearTimeout(timer)

        }
    </script>
</body>
</html>